package com.example.juc.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

public class CallableTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        new Thread(new MyThread()).start();

        MyThread2 thread2 = new MyThread2();

        FutureTask<Integer> task = new FutureTask<>(thread2);
        new Thread(task).start();
        new Thread(task).start();
    }
}



class MyThread implements Runnable{

    @Override
    public void run() {
        System.out.println("Say hello");
    }
}


class MyThread2 implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        System.out.println("111");
        return 1;
    }
}